package com.example.designpatterns.composite;

/**
 * 树叶构件（Leaf）
 */
public class FileItem extends FileComponent {
    public FileItem(String name, Integer level, Integer type) {
        this.name = name;
        this.level = level;
        this.type = type;
    }

    @Override
    public void add(FileComponent fileComponent) {

    }

    @Override
    public void remove(FileComponent fileComponent) {

    }

    @Override
    public FileComponent getChild(int index) {
        return null;
    }

    @Override
    public void print() {
        //打印文件的名称
        for (int i = 0; i < level; i++) {
            System.out.print("\t");
        }
        System.out.println(name);
    }
}
